<template>
  <div class="order-chart">
    <div class="content">
      <div class="roll-box">
        <img src="@/assets/images/kaidu/ball-bg.png" alt="" />
      </div>
      <ul class="item-box">
        <li v-for="item in list">
          <img :src="item.icon" alt="" />
          <div class="info">
            <span class="item-name">{{ item.name }}</span>
            <span class="item-value">{{ item.value }}</span>
            <span class="item-unit">{{ item.unit }}</span>
          </div>
        </li>
      </ul>
      <div class="totals">
        <span class="num">{{total}}</span>
        <span class="tips">今年累计产量</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, watch } from 'vue'
import arrowBlue from '@/assets/images/kaidu/arrow-blue.png'
import arrowGreen from '@/assets/images/kaidu/arrow-green.png'
import arrowYellow from '@/assets/images/kaidu/arrow-yellow.png'
import arrowPurle from '@/assets/images/kaidu/arrow-purple.png'

const props = defineProps(['data'])
let list = ref([
  {
    icon: arrowBlue,
    name: '本月新接收订单总数',
    value: 0,
    unit: '套'
  },
  {
    icon: arrowYellow,
    name: '待排产销售单',
    value: 0,
    unit: '套'
  },
  {
    icon: arrowPurle,
    name: '本月应/实际出货数',
    value: 0,
    unit: '套'
  },
  {
    icon: arrowGreen,
    name: '本月入库/发货数',
    value: 0,
    unit: '套'
  }
])
let total = ref(0)
watch(
  () => props.data,
  (n, o) => {
    list.value = [
      {
        icon: arrowBlue,
        name: '本月新接收订单总数',
        value: n.thisMonthOrderNum,
        unit: '套'
      },
      {
        icon: arrowYellow,
        name: '待排产销售单',
        value: n.productionScheduleSalesNum,
        unit: '套'
      },
      {
        icon: arrowPurle,
        name: '本月应/实际出货数',
        value:
          n.thisMonthShouldOutboundNum + '/' + n.thisMonthActualOutboundNum,
        unit: '套'
      },
      {
        icon: arrowGreen,
        name: '本月入库/发货数',
        value: n.thisMonthWarehouseNum + '/' + n.outboundNum,
        unit: '套'
      }
    ]
    total.value = n.thisYearProductNum
  }
)
onMounted(() => {})
</script>

<style lang="scss" scoped>
.order-chart {
  width: 100%;
  height: 100%;
  background: url('@/assets/images/kaidu/order-border.png') no-repeat;
  background-size: 100% 96%;
  background-position: center;
  overflow: hidden;
  position: relative;
  .content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('@/assets/images/kaidu/order-bg.png');
    overflow: hidden;
  }
  .roll-box {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .item-box {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    font-size: 18px;
    li {
      width: 50%;
      position: relative;
    }
    li:nth-child(1) {
      img {
        position: absolute;
        right: 8%;
        top: 22%;
      }
      .info {
        top: 28%;
        left: 7%;
        align-items: flex-end;
      }
    }
    li:nth-child(2) {
      img {
        position: absolute;
        left: 14%;
        top: 22%;
      }
      .info {
        top: 28%;
        right: 2%;
        align-items: flex-start;
      }
    }
    li:nth-child(3) {
      img {
        position: absolute;
        right: 8%;
        top: 12%;
      }
      .info {
        top: 20%;
        left: 7%;
        align-items: flex-end;
      }
    }
    li:nth-child(4) {
      img {
        position: absolute;
        left: 14%;
        top: 12%;
      }
      .info {
        top: 20%;
        right: 2%;
        align-items: flex-start;
      }
    }
  }
  .info {
    position: absolute;
    width: 50%;
    align-self: auto;
    display: flex;
    flex-direction: column;
    .item-name {
      font-family: Source Han Sans CN;
      font-weight: 400;
      font-size: 18px;
      color: #c7dffc;
    }
    .item-value {
      font-family: DIN;
      font-weight: bold;
      font-size: 32px;
      color: #ffffff;
      margin: 5px 0;
      text-shadow: 0 0 14px rgba(2, 139, 255, 0.56),
        0 0 14px rgba(2, 139, 255, 0.56);
    }
    .item-unit {
      font-family: Source Han Sans CN;
      font-weight: 400;
      font-size: 16px;
      color: #c7dffc;
      line-height: 23px;
      opacity: 0.6;
    }
  }

  .totals {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    .num {
      margin-top: 20px;
      font-family: DIN;
      font-weight: bold;
      font-size: 56px;
      color: #ffffff;
      line-height: 52px;
      text-shadow: 0 0 14px rgba(2, 139, 255, 0.56),
        0 0 14px rgba(2, 139, 255, 0.56);
    }
    .tips {
      margin-top: 15px;
      font-weight: 400;
      font-size: 28px;
      color: #c7dffc;
    }
  }
}
</style>
